package com.telit.uav.controller;

import com.telit.common.entity.DataReturn;
import com.telit.uav.entity.AppCruiseTrack;
import com.telit.uav.service.impl.AppCruiseTrackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Auther amy
 * @Describe 巡航轨迹
 */
@RestController
@RequestMapping("/app-cruise-track")
@Api(tags = "巡航轨迹表",description = "/app-cruise-track")
public class AppCruiseTrackController {

    @Autowired
    private AppCruiseTrackService appCruiseTrackService;

    @GetMapping(value = "/list/{protectorId}",produces = "application/json;charset=UTF-8")
    @ApiOperation("单个飞手巡航信息无分页查询")
    public DataReturn listByProtectorId(@PathVariable("protectorId") Long protectorId, AppCruiseTrack appPatrolTrack){
        appPatrolTrack.setProtectorId(protectorId);
        return DataReturn.ok(appCruiseTrackService.listByProtectorId(appPatrolTrack));
    }

    @GetMapping(value = "/count",produces = "application/json;charset=UTF-8")
    @ApiOperation("巡航轨迹统计数据")
    public DataReturn cruiseTrackInfo(){
        return DataReturn.ok(appCruiseTrackService.selectCruiseCount());
    }


    /**
     * 2022-07-04 追加数据权限-巡航轨迹统计信息
     * 查询巡航数据信息
     *
     * @param userIds 用户id 集合
     * @return 查询结果集
     */
    @PostMapping(value = "/countByUserId", produces = "application/json;charset=UTF-8")
    @ApiOperation("巡航轨迹统计数据")
    public DataReturn cruiseTrackInfoByUserId(@RequestBody List<Long> userIds) {
        return DataReturn.ok(appCruiseTrackService.selectCruiseCountByUserId(userIds));
    }


    /**
     * 首页巡护总次数
     * @param userIds 用户id 集合
     * @return 查询结果集
     */
    @PostMapping(value = "/selectcountByUserId", produces = "application/json;charset=UTF-8")
    @ApiOperation("巡航轨迹统计数据")
    public DataReturn selectcountByUserId(@RequestBody List<Long> userIds) {
        return DataReturn.ok(appCruiseTrackService.selectcountByUserId(userIds));
    }

}
